package algorithm;

/**
 * 删除重复出现一次的数组，使数组的每一个元素都只出现过一次
 */
public class LeetCode_removeDuplicates_26 {
    public int removeDuplicates(int[] nums) {
        int len = nums.length;
        if (len < 2) {
            return len;
        }
        int low = 1, fast = 1;
        while (fast < len) {
            if (nums[low - 1] != nums[fast]) {
                nums[low] = nums[fast];
                low++;
            }
            fast++;
        }
        return low;
    }
}
